package cn.qn.controller.apply;

import cn.qn.base.PageVO;
import cn.qn.dto.ResponseDTO;
import cn.qn.dto.apply.ChargerBuildApplyDTO;
import cn.qn.dto.apply.ChargerBuildApplyQueryDTO;
import cn.qn.dto.team.RecruitDTO;
import cn.qn.dto.team.RecruitQueryDTO;
import cn.qn.exceptions.BizException;
import cn.qn.framwork.security.MemberAccountUtils;
import cn.qn.service.apply.ChargerBuildApplyService;
import cn.qn.service.team.RecruitService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Bryant
 * @date: 2019/5/31
 * @description:
 */
@RestController
@RequestMapping("/charger/apply")
public class ChargerBuildApplyController {

    @Reference(check = false,timeout = 30000)
    private ChargerBuildApplyService chargerBuildApplyService;

    @RequestMapping(value = "/list" ,name="建桩列表接口",method = RequestMethod.GET)
    public ResponseDTO list(ChargerBuildApplyQueryDTO query){
        PageVO<ChargerBuildApplyDTO> applies = chargerBuildApplyService.pageQueryChargerApply(query);
        return ResponseDTO.success(applies);
    }

    @RequestMapping(value = "/detail/{id}" ,name="建桩详情接口",method = RequestMethod.GET)
    public ResponseDTO detail(@PathVariable(value = "id") Integer id){
        ChargerBuildApplyDTO apply = chargerBuildApplyService.queryDetailById(id);
        return ResponseDTO.success(apply);
    }

    @RequestMapping(value = "/handle" ,name="处理申请接口",method = RequestMethod.POST)
    public ResponseDTO handle(@RequestBody ChargerBuildApplyDTO dto){
        try {
            dto.setUpdateBy(MemberAccountUtils.getCurrentMember().getUsername());
            chargerBuildApplyService.handle(dto);
            return ResponseDTO.success();
        }catch (BizException e){
            return ResponseDTO.error(e.getMessage());
        }
    }
}
